import { request } from "@/utils/http";

//请求医院列表参数的类型限制
import type {
  getHosListSearchParamsType,
  hospitalListReqReturnType,
  getProvinceReturnType,
  getHospDetailType,
  hosDepartmentListType,
  hosScheduleRuleParamsType,
  hosScheduleRuleReturnType,
  findScheduleListParamsType,
  findScheduleListType
} from "./model/hospitalListType";
//1.获取医院列表数据请求
export const getHospitalListRequest = (
  page: number,
  limit: number,
  searchParams: getHosListSearchParamsType
) => {
  return request.get<any, hospitalListReqReturnType>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: searchParams,
    }
  );
};

//2.请求所有的省份

export const getProvinceReturnRequest = () => {
  return request.get<any, getProvinceReturnType>(
    "/admin/cmn/dict/findByDictCode/province"
  );
};

//3.根据value值请求市/县
export const getCityOrCountyRequest = (value: string) => {
  return request.get<any, getProvinceReturnType>(
    `/admin/cmn/dict/findByParentId/${value}`
  );
};

//4. 根据id获取医院的详情
export const getHosDetailRequest = (id: string) => {
  return request.get<any, getHospDetailType>(`/admin/hosp/hospital/show/${id}`);
};

//5.根据 status 改变上线和下线
export const getControlStatusRequest = (id: string, status: number) => {
  return request.get<any, null>(
    `/admin/hosp/hospital/updateStatus/${id}/${status}`
  );
};

//6.根据hosCode获取医院所有科室数据
export const gtHosDepartmentListRequest = (hoscode: string) => {
  return request.get<any, hosDepartmentListType>(
    `/admin/hosp/department/${hoscode}`
  );
};

//7.获取医院科室的排版时间
export const getHosScheduleRuleRequest = ({
  page,
  limit,
  hoscode,
  depcode,
}: hosScheduleRuleParamsType) => {
  return request.get<any,hosScheduleRuleReturnType>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
};

//8.获取某个科室某个时间具体详情
export const findScheduleListRequest = ({ hoscode, depcode, workDate }:findScheduleListParamsType) => {
    return request.get<any , findScheduleListType>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}
